<?php

namespace App\Library\Logic;

use App\Library\Requests\Base\BasePageRequest;
use App\Models\ShopUserAddressModel;
use Illuminate\Support\Facades\DB;

class ShopUserAddressLogic extends ShopUserAddressModel
{
    /**
     * handle
     * @param int $userId
     * @return array
     */
    public static function getReturnAddress(int $userId): array
    {
        return self::query()->where(['user_id' => $userId, 'ua_is_refund' => 1,])->pluck(
            DB::raw("concat(ua_contacts,'/',ua_contacts_mobile,'/',ua_address_full)"), 'ua_id'
        )->toArray();
    }

    public function paging(BasePageRequest $request): array
    {
        return paginate(
            self::query()->where('user_id', USERID)->orderByDesc('ua_id')->paginate($request->limit),
        );
    }
}
